package zhongbo.java.air.dictionary.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;
import zhongbo.java.air.dictionary.model.AirCraft;
import zhongbo.java.air.dictionary.model.Airport;
import zhongbo.java.air.dictionary.model.Dto.PageDto;
import zhongbo.java.air.dictionary.service.serverImpl.AirportServerImpl;
import zhongbo.java.air.dictionary.service.serverImpl.IAirCraftServiceImpl;

/**
 * 说明：
 * 飞机基础信息操作的相关接口
 *
 * @author 钟波dellNotebook
 * @since 2025年03月31日 星期一 08:30:28
 */

@RestController
@RequestMapping("/airport")
@Api(tags = "机场信息相关接口")
public class AirProtController {
    @Autowired
    private AirportServerImpl AirportService;

    //分页查寻
    @GetMapping("/slelectpage")
    @ApiOperation(value = "机场信息列表", notes = "分页查询", httpMethod = "GET", response = ResultVo.class)
    private ResultVo<PageVo<Airport>> selectPage(int pageNum,int pageSize,String sortField,boolean isAsc){
        PageDto pageDto = new PageDto(pageNum, pageSize, sortField, isAsc);
        PageVo<Airport> airportPageVo = AirportService.selectPage(pageDto);
        return ResultVo.ok(airportPageVo);
    }

    //增加
    @PostMapping("/add")
    @ApiOperation(value = "添加", notes = "添加机场信息", httpMethod = "POST", response = ResultVo.class)
    private ResultVo<Object> add(@RequestBody Airport airport){
        AirportService.addAirport(airport);
        return ResultVo.ok(null);
    }

    //删除
    @ApiOperation(value = "删除", notes = "删除机场信息", httpMethod = "DELETE", response = ResultVo.class)
    @DeleteMapping("/delete/{id}")
    private ResultVo<Object> delete(@PathVariable String id){
        AirportService.deleteById(id);
        return ResultVo.ok(null);
    }

    //修改
    @PutMapping("/update")
    @ApiOperation(value = "修改", notes = "修改机场信息", httpMethod = "PUT", response = ResultVo.class)
    private ResultVo<Object> update(@RequestBody Airport airport){
        AirportService.updateAirport(airport);
        return ResultVo.ok(null);
    }
}
